package org.fujay.langchain4jserver.domain.application.vo;

import java.io.Serial;
import java.io.Serializable;

/**
 * 应用配置版本值对象
 */
public record Version(int value) implements Serializable, Comparable<Version> {
    @Serial
    private static final long serialVersionUID = 1L;

    public Version {
        if (value <= 0) {
            throw new IllegalArgumentException("Version number must be positive");
        }
    }

    public static Version initial() {
        return new Version(1);
    }

    public Version next() {
        return new Version(this.value + 1);
    }

    @Override
    public int compareTo(Version other) {
        return Integer.compare(this.value, other.value);
    }
}
